package com.wewins.fota.common.constant;

import lombok.Getter;

public enum FotaCode {
    NONE(-1, "未知"),
    COMMON_SUCCESS(0, "成功"),
    COMMON_FAILED(1, "失败"),
    NO_UPDATE(2, "无更新"),
    HAS_UPDATE(3, "有更新"),
    DOWNLOAD_OK(4, "下载成功"),
    DOWNLOAD_FAILED(5, "下载失败"),

    UPDATE_TYPE_HANDLE(500, "手动"),
    UPDATE_TYPE_AUTO(501, "自动"),
    LOG_OPERATE_QUERY(502, "查询"),
    LOG_OPERATE_DOWNLOAD(503, "下载"),


    DOWNLOAD_STATUS_TITLE(1000, "下载状态"),
    INSTALL_STATUS_TITLE(1001, "安装状态"),

    EXPORT_ALL(2000, "导出所有"),
    EXPORT_4_YTL(2001, "YTL导出"),
    CMD_ADD_PKG(2002, "新增版本"),
    CMD_UPDATE_PKG(2003, "修改版本"),
    CMD_DELETE_PKG(2004, "删除版本"),
    CMD_ADD_PLAN(2005, "新增升级计划"),
    CMD_UPDATE_PLAN(2006, "修改升级计划"),
    CMD_DELETE_PLAN(2007, "删除升级计划"),
    CMD_VERSION_QUERY(2008, "版本升级状态查询"),
    ;

    @Getter
    private int code;

    @Getter
    private String message;

    FotaCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static FotaCode getInstance(int code) {
        for (FotaCode mapping : values()) {
            if (mapping.code == code) {
                return mapping;
            }
        }
        return NONE;
    }

}
